package com.weixin.junit;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;


import com.weixin.message.openid.TextMessage;
import com.weixin.pojo.Token;
import com.weixin.pojo.WeixinUserList;
import com.weixin.util.AdvancedUtil;
import com.weixin.util.CommonUtil;
import com.weixin.util.GroupSendUtil;


public class MyJob implements Job{
public static void main(String[] args) {
	sendWeixinMsg();
}
    @Override
    public void execute(JobExecutionContext arg0) throws JobExecutionException {
    	sendWeixinMsg();
    }
    public static void sendWeixinMsg() 
    {
    	Token token=CommonUtil.getToken("wx85686af5d3eca3e1","74f66edda885b35f29745f2490f82cfd");

		String accessToken=token.getAccessToken();
		WeixinUserList user=AdvancedUtil.getUserList(accessToken, null);	
		List<String> openIdList= user.getOpenIdList();
		for(String openId:openIdList)
		{
		List<String> list= new ArrayList<>();
		list.add(openId);
		list.add(openId);
		TextMessage textmessage=new TextMessage();
		textmessage.setTouser(list);
		textmessage.setMsgtype("text");
		Map<String,String> text=new HashMap<>();
		String content ="123";
		try {
			//content = "1233"+ com.weixin.listener.WeatherJob.getWeatherByOpenId(openId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		};	
		text.put("content",content);
		textmessage.setText(text);
		String str = GroupSendUtil.sendMsgByOpenId(accessToken, list, textmessage);
		System.out.println(str);
		}
    }

}
